package com.yoda.mall.admin.service;

import com.yoda.mall.api.OrderReturnApplyApi;
import com.yoda.mall.model.dto.ReturnApplyPageDto;
import com.yoda.mall.model.dto.StatusDto;
import com.yoda.mall.model.entity.oms.OrderReturnApply;
import com.yoda.mall.model.vo.PageResult;
import com.yoda.mall.model.vo.R;
import com.yoda.mall.model.vo.ReturnApplyVo;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.text.ParseException;
import java.util.List;

/**
 * @author shawn
 * @date 2022年 12月 18日 21:09
 */
@Service
public class OrderReturnApplyService {

    @DubboReference
    private OrderReturnApplyApi orderReturnApplyApi;


    public PageResult<OrderReturnApply> getReturnApplyByPage(ReturnApplyPageDto dto) throws ParseException {
        //参数转换
        OrderReturnApply returnApply = ReturnApplyPageDto.init(dto);

        return orderReturnApplyApi.getReturnApplyByPage(dto.getPageNum(),dto.getPageSize(),returnApply);
    }

    public Integer deleteReturnApply(List<Long> ids) {
        return orderReturnApplyApi.deleteReturnByIds(ids);
    }

    public ReturnApplyVo getReturnApplyById(Long id) {
        return orderReturnApplyApi.getReturnApplyById(id);
    }

    public Integer updateStatus(StatusDto statusParam) {
        OrderReturnApply returnApply = new OrderReturnApply();
        BeanUtils.copyProperties(statusParam,returnApply);
        return orderReturnApplyApi.updateStatus(returnApply);
    }
}
